<?php
//客户管理类
class ClientAction extends CommonAction {
	public function index() {
		parent::userauth2(108);
		$data['start'] = empty($_GET['page'])?0:($_GET['page']-1)*15;
		$data['pageSize'] = 15;
		$html = send_post(C('URL').'/eduWeb/apply/getTeacherList',$data);

		$count = $html['data']['count'];
		$user = $html['data']['userList'];
		//dump($html);
		import('ORG.Util.Page');				// 导入分页类
		$pagenum = isset ( $_REQUEST ['page'] ) ? $_REQUEST ['page'] : 1;
		$page_row = 15;//每页显示条数
		//dump($count);
		$p = new Page ($count,$page_row,8);
		$p->isJumpPage = true;
		$p->setConfig('theme','%totalRow% %header% %nowPage%/%totalPage% 页%first% %upPage% %linkPage% %downPage% %end% %jump%');
		$show = $p->show();
		//dump($show);
		$this->assign('user',$user);
		// $this->assign('maxpage',$maxpage);
		$this->assign('key',$keyWord);
		$this->assign('page',$show);
		$this->assign('newsurl',C('NEWSURL'));
		$this->assign('url',C('URL'));
		$this->assign('admin',$_SESSION['ThinkUser']);
		$this->display();
	}



	public function teacherList() {
		parent::userauth2(89);
		$this->getsearchparam();
		$data['start'] = empty($_GET['page'])?0:($_GET['page']-1)*6;
		$data['pageSize'] = 6;
		$html = send_post(C('URL').'/eduWeb/teacher/querysysTeacher',$data);
		$count = $html['data']['count'];
		$user = $html['data']['userLise'];
		
		import('ORG.Util.Page');				// 导入分页类
		$pagenum = isset ( $_REQUEST ['page'] ) ? $_REQUEST ['page'] : 1;
		$page_row = 6;//每页显示条数
		$p = new Page ($count,$page_row,6);

		$p->isJumpPage = true;
		$p->setConfig('theme','%totalRow% %header% %nowPage%/%totalPage% 页%first% %upPage% %linkPage% %downPage% %end% %jump%');
		$show = $p->show();
		$this->assign('user',$user);
		$this->assign('key',$keyWord);
		$this->assign('page',$show);
		$this->assign('newsurl',C('NEWSURL'));
		$this->assign('url',C('URL'));
		$this->assign('admin',$_SESSION['ThinkUser']);
		$this->display();
	}


	public function userlist() {
		parent::userauth2(89);
		$this->getsearchparam();
		$data['start'] = empty($_GET['page'])?0:($_GET['page']-1)*6;
		$data['pageSize'] = 6;
		$data['approveStatus'] = empty($_GET['s'])?' ':$_GET['s'];
		$html = send_post(C('URL').'/eduWeb/user/getUsers',$data);
		$count = $html['data']['count'];
		$user = $html['data']['userList'];
		//dump($html);
		import('ORG.Util.Page');				// 导入分页类
		$pagenum = isset ( $_REQUEST ['page'] ) ? $_REQUEST ['page'] : 1;
		$page_row = 6;//每页显示条数
		$p = new Page ($count,$page_row,6);

		$p->isJumpPage = true;
		$p->setConfig('theme','%totalRow% %header% %nowPage%/%totalPage% 页%first% %upPage% %linkPage% %downPage% %end% %jump%');
		$show = $p->show();
		$this->assign('user',$user);
		$this->assign('key',$keyWord);
		$this->assign('page',$show);
		$this->assign('newsurl',C('NEWSURL'));
		$this->assign('url',C('URL'));
		$this->assign('admin',$_SESSION['ThinkUser']);
		$this->display();
	}

	//用户详情信息
	public function user(){
		$data['sid']= $_GET['sid'];
		$html = send_post(C('URL').'/eduWeb/apply/getTeacherDetail',$data);
		//dump($html);
		$this->assign('user',$html['data']['user']);
		$this->assign('url',C('URL'));
		$this->display();
	}

	public function userinfo(){
		$data['userId'] = $_GET['sid'];
		$html = send_post(C('URL').'/eduWeb/user/getUsersDetail',$data);
		//dump($html['data']['userDetail']);
		
		if($html['data']['userDetail']){
			$this->assign('certificatePicture',$html['data']['certlist']);
			$this->assign('user',$html['data']['userDetail']);
			$this->assign('url',C('URL'));
			$this->display();
		}else{
			echo '待用户上传资料信息';
		}
		
	}

	public function getsearchparam()
	{
		//获取用户状态
		$this->assign('status', D('status')->field('id, name, value')->order('id asc')->where('pid = 1')->select());
	}


	//时间美化函数
	protected function Beautifytime($dtime) {
		$dtime = strtotime($dtime);
		$betime = time()-$dtime;
		$timename='';
		switch($betime) {
			case ($betime < 60):
				$timename = floor($betime).'秒前';
				break;
			case ($betime < 3600 && $betime > 60):
				$timename = floor(($betime/60)).'分钟前';
				break;
			case ($betime < 86400 && $betime > 3600):
				$timename = floor(($betime/60/60)).'小时前';
				break;
			case ($betime < 2592000 && $betime > 86400):
				$timename = floor(($betime/60/60/30)).'天前';
				break;
			case ($betime < 31536000 && $betime > 2592000):
				$timename = floor(($betime/60/60/30/12)).'个月前';
				break;
			case ($betime < 3153600000 && $betime > 31536000):
				$timename = floor(($betime/60/60/30/12/100)).'年前';
				break;
		}
		return $timename;
	}

}
?>

